# if not utility.has_collection(DOC_COLLECTION_NAME):
from pymilvus import (
    connections,
    FieldSchema,
    DataType,
    CollectionSchema,
    Collection,
    utility,
)

connections.connect(
    "default", host="192.168.1.62", port="19530", db_name="zhangrenyang"
)
# 定义集合的字段结构
fields = [
    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
    FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=128),
]
# 定义集合的名称
collection_name = "blog"
# 创建集合的模式对象
schema = CollectionSchema(fields, description=collection_name)

try:
    if not utility.has_collection(collection_name):
        # 创建新的集合
        collection = Collection(collection_name, schema)
except Exception as e:
    print(e)
